//
//  CJCommentTableViewCell.m
//  CoJellyCartoon
//
//  Created by dllo on 16/4/7.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "CJCommentTableViewCell.h"

@implementation CJCommentTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.authorPic = [[UIImageView alloc] initWithFrame:CGRectZero];
        
//        self.authorPic.backgroundColor = [UIColor orangeColor];
        self.authorPic.layer.masksToBounds = YES;
        [self addSubview:self.authorPic];
        
        self.authorLabel = [[CJBaseLabel alloc] initWithFrame:CGRectZero];
        self.authorLabel.font = [UIFont systemFontOfSize:15];
        self.authorLabel.textColor = [UIColor lightGrayColor];
//        self.authorLabel.backgroundColor = [UIColor cyanColor];
        [self addSubview:self.authorLabel];
        
        self.floor = [[CJBaseLabel alloc] initWithFrame:CGRectZero];
        self.floor.font = [UIFont systemFontOfSize:14];
        self.floor.textColor = [UIColor lightGrayColor];
//        self.floor.backgroundColor = [UIColor blueColor];
        [self addSubview:self.floor];
        
        self.comment = [[CJBaseLabel alloc] initWithFrame:CGRectZero];
        self.comment.font = [UIFont systemFontOfSize:16];
        self.comment.numberOfLines = 2;
//        self.comment.backgroundColor = [UIColor greenColor];
        [self addSubview:self.comment];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    self.authorPic.frame = CGRectMake(10, 10, 50, 50);
    self.authorPic.layer.cornerRadius = self.authorPic.bounds.size.width / 2;
    self.authorLabel.frame = CGRectMake(self.authorPic.bounds.origin.x + self.authorPic.bounds.size.width + 20, 10, 200, 20);
    self.floor.frame = CGRectMake(self.authorPic.bounds.origin.x + self.authorPic.bounds.size.width + 20, self.authorLabel.bounds.origin.y + self.authorLabel.bounds.size.height, 100, 40);
    
    self.comment.frame = CGRectMake(self.authorPic.bounds.origin.x + self.authorPic.bounds.size.width + 20, self.floor.bounds.origin.y+self.floor.bounds.size.height+10, self.bounds.size.width-self.authorPic.bounds.size.width -5 , 60);
    
}

-(void)setCommentReplyModel:(CJCommentReplies *)commentReplyModel{
    _commentReplyModel = commentReplyModel;
    [self.authorPic sd_setImageWithURL:[NSURL URLWithString:commentReplyModel.member[@"avatar"]]];
    self.authorLabel.text = commentReplyModel.member[@"uname"];
    self.floor.text = [NSString stringWithFormat:@"#%@",commentReplyModel.floor];
    self.comment.text = commentReplyModel.content[@"message"];
}
@end
